window.onload = function () {
    var up=document.getElementById('upButton');
    var count=document.getElementById('countView');
    var down=document.getElementById('dowmButton');
    var submit=document.getElementById('submitButton');
    var likeBay=document.getElementById('LikBuy');
    
    up.onclick=function(){
        var val = parseInt(count.value);
        if(val >= 99){
        	count.value = 99;
        }else{
        	count.value = val + 1;
        }
    }
    down.onclick=function(){
        var val = parseInt(count.value);
        if(val <= 1){
        	count.value = 1;
        }else{
        	count.value = val - 1;
        }
    }
    
    count.onkeyup = function () {
        var val = parseInt(count.value);
        if (isNaN(val) || val < 1) {
        	val = 1;
        }
        else if(val > 99){
        	val = 99;
        }
        count.value=val;        
    }
    submit.onclick = function () {
         var productObjId=parseInt(document.getElementById('productObjId').value);
         var val=parseInt(count.value);
         window.location.href="addTOShoppingCarAction.action?furnitureInfo.objId="+productObjId+"&count="+val;
    }
    likeBay.onclick = function () {
        var productObjId=parseInt(document.getElementById('productObjId').value);
        var val=parseInt(count.value);
        window.location.href="addToPayAction.action?furnitureInfo.objId="+productObjId+"&count="+val;
   }
}

